package com.skycan.plc.adapter.protocol.modbus;

/**
 * Modbus协议常量
 */
public class ModbusConstants {

    // Modbus功能码
    public static final int READ_COILS = 1; // 读取线圈状态
    public static final int READ_DISCRETE_INPUTS = 2; // 读取离散输入状态
    public static final int READ_HOLDING_REGISTERS = 3; // 读取保持寄存器
    public static final int READ_INPUT_REGISTERS = 4; // 读取输入寄存器
    public static final int WRITE_SINGLE_COIL = 5; // 写单个线圈
    public static final int WRITE_SINGLE_REGISTER = 6; // 写单个寄存器
    public static final int WRITE_MULTIPLE_COILS = 15; // 写多个线圈
    public static final int WRITE_MULTIPLE_REGISTERS = 16; // 写多个寄存器

    // Modbus地址前缀
    public static final String COIL_PREFIX = "0"; // 线圈地址前缀
    public static final String DISCRETE_INPUT_PREFIX = "1"; // 离散输入地址前缀
    public static final String INPUT_REGISTER_PREFIX = "3"; // 输入寄存器地址前缀
    public static final String HOLDING_REGISTER_PREFIX = "4"; // 保持寄存器地址前缀

    // Modbus连接超时(毫秒)
    public static final int CONNECTION_TIMEOUT = 3000;

    // Modbus重试次数
    public static final int RETRY_COUNT = 3;

    // Modbus从站ID
    public static final int DEFAULT_UNIT_ID = 1;

    // 私有构造函数，防止实例化
    private ModbusConstants() {
    }
}